<template>
	<view>
		<navbar left-text="主页" :titleText="titleText" />
		<view class="detail-list">
			<view class="list" v-for="(item, index) in detailList" :key="index" @click="goDetail(item)">
				<image :src="item.imgUrl" alt="">
				<text>{{item.text}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar.vue'
	import navbar from '@/components/navbar.vue'
	export default {
		data() {
			return {
				tabId: '',
				titleText: '',
				detailList: [
					{ id: 1, imgUrl: '/static/imgs/inrece.png', text: '器材登记'},
					{ id: 2, imgUrl: '/static/imgs/outaffi.png', text: '器材领取'},
					{ id: 3, imgUrl: '/static/imgs/checkaffi.png', text: '盘点确认'},
					{ id: 5, imgUrl: '/static/imgs/inrece.png', text: '空框登记'},
					{ id: 6, imgUrl: '/static/imgs/outaffi.png', text: '空框呼叫'},
				]
			};
		},
		components: {
			tabbar,
			navbar
		},
		// 初始化获取传参
		onLoad() {
			let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			let curRoute = routes[routes.length - 1].route //获取当前页面路由
			let curParam = routes[routes.length - 1].options; //获取路由参数
			this.tabId = curParam.tabId
			this.titleText = curParam.type
			console.log(curParam)
			this.initList()
		},
		methods: {
			// 根据点击的类型渲染相应列表
			initList() {
				this.detailList = this.detailList.filter(item => item.id == this.tabId)
			},
			goDetail(item) {
				uni.setStorageSync('backParams', {tabId: this.tabId, titleText: this.titleText})
				let k_v = {
					"入库登记": "/pages/wms/purchase/index",
					"出库确认": "/pages/wms/order/order_confirm/index",
					"任务取消": "/pages/wms/order/order_cancel/index",
					"盘点确认": "/pages/wms/check/index",
					"空框登记": "/pages/wms/empty/empty_in/index",
					"空框呼出": "/pages/wms/empty/empty_ot/index",
				}
				uni.navigateTo({
					url:k_v[item.text]
				})
			}
		},
	}
</script>

<style lang="scss">
	.detail-list {
			margin-top: 50px;
	}
.list {
	padding: 15px 30px;
	border-bottom: 1px solid #dadadc;
	font-size: 18px;
	color: #756e6e;
	display: flex;
	align-items: center;
	image {
		width: 35px;
		height: 35px;
		margin-right: 10px;
	}
}
</style>
